#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 1e4+7;
const int MOD = 10001;
int X[MAXN];
int n;
int POWM(int a, int k, int m) {
	int ret=1; 
	while (k) {
		if (k&1) {
			ret = (ret*a) % m;
		}
		a=(a*a) % MOD;
		k=(k>>1);
	}
	return ret;
}
bool check(int a, int b) {
	for (int i=1; i<n; ++i) {
		int l = (X[i]%MOD-a*a%MOD*X[i-1]%MOD+MOD) % MOD;
		int r = (a+1)*b % MOD;
		if (l!=r) return false;
	}
	return true;
}
int main(int argc, char** argv) {
//	for (int i=1; i<MOD; ++i) if (MOD%i==0) printf("%d\n", i);
	#ifdef hai
	freopen("in.txt", "r", stdin);
	#endif
	while (~scanf("%d", &n)) {
		for (int i=0; i<n; ++i) {
			scanf("%d", X+i);
		}
		int a,b;
		for (a=0; a<MOD; ++a) {
			if (a==72 || a==136) continue;
			int x3=X[1], x1=X[0];
//			cout<<"here: "<<POWM(a+1, 72*136-1, MOD)<<endl;
			b=(x3%MOD-a*a%MOD*x1%MOD+MOD) * POWM(a+1, 72*136-1, MOD) % MOD;
			if (check(a,b)) {
//				printf("here: %d %d\n", a, b);
				break;
			}
		}
//		printf("a,b: %d %d\n", a, b);
		for (int i=0; i<n; ++i) {
//			printf("X: %d\n", X[i]);
			printf("%d\n", (a*X[i]+b+MOD)%MOD);
		}
	}
	return 0;
}
